import request from '@/utils/request'

// 批量启用设备
export function batchEnableDevices(deviceIds) {
  return request({
    url: '/devices/batch/enable',
    method: 'post',
    data: { deviceIds }
  })
}

// 批量禁用设备
export function batchDisableDevices(deviceIds) {
  return request({
    url: '/devices/batch/disable',
    method: 'post',
    data: { deviceIds }
  })
}

// 批量刷新设备
export function batchRefreshDevices(deviceIds) {
  return request({
    url: '/devices/batch/refresh',
    method: 'post',
    data: { deviceIds }
  })
}

// 批量删除设备
export function batchDeleteDevices(deviceIds) {
  return request({
    url: '/devices/batch/delete',
    method: 'post',
    data: { deviceIds }
  })
}

// 批量时间同步
export function batchSyncTime(deviceIds, timeConfig) {
  return request({
    url: '/devices/batch/time/sync',
    method: 'post',
    data: {
      deviceIds,
      timeConfig
    }
  })
}

// 批量重启设备
export function batchRebootDevices(deviceIds) {
  return request({
    url: '/devices/batch/reboot',
    method: 'post',
    data: { deviceIds }
  })
}

// 批量网络配置
export function batchConfigNetwork(deviceIds, networkConfig) {
  return request({
    url: '/devices/batch/network/config',
    method: 'post',
    data: {
      deviceIds,
      networkConfig
    }
  })
}

// 批量时间配置
export function batchConfigTime(deviceIds, timeConfig) {
  return request({
    url: '/devices/batch/time/config',
    method: 'post',
    data: {
      deviceIds,
      timeConfig
    }
  })
}

// 批量录像配置
export function batchConfigRecording(deviceIds, recordingConfig) {
  return request({
    url: '/devices/batch/recording/config',
    method: 'post',
    data: {
      deviceIds,
      recordingConfig
    }
  })
}

// 批量导出配置
export function batchExportConfig(deviceIds) {
  return request({
    url: '/devices/batch/config/export',
    method: 'post',
    data: { deviceIds },
    responseType: 'blob'
  })
}

// 批量开始录像
export function batchStartRecording(channelIds, recordingConfig) {
  return request({
    url: '/channels/batch/recording/start',
    method: 'post',
    data: {
      channelIds,
      recordingConfig
    }
  })
}

// 批量停止录像
export function batchStopRecording(channelIds) {
  return request({
    url: '/channels/batch/recording/stop',
    method: 'post',
    data: { channelIds }
  })
}

// 批量订阅事件
export function batchSubscribeEvents(deviceIds, eventConfig) {
  return request({
    url: '/devices/batch/events/subscribe',
    method: 'post',
    data: {
      deviceIds,
      eventConfig
    }
  })
}

// 批量取消订阅事件
export function batchUnsubscribeEvents(deviceIds, subscriptionIds) {
  return request({
    url: '/devices/batch/events/unsubscribe',
    method: 'post',
    data: {
      deviceIds,
      subscriptionIds
    }
  })
}

// 获取批量操作状态
export function getBatchOperationStatus(operationId) {
  return request({
    url: `/batch/operations/${operationId}/status`,
    method: 'get'
  })
}

// 获取批量操作结果
export function getBatchOperationResult(operationId) {
  return request({
    url: `/batch/operations/${operationId}/result`,
    method: 'get'
  })
}

// 取消批量操作
export function cancelBatchOperation(operationId) {
  return request({
    url: `/batch/operations/${operationId}/cancel`,
    method: 'post'
  })
}

// 获取批量操作历史
export function getBatchOperationHistory(params) {
  return request({
    url: '/batch/operations/history',
    method: 'get',
    params
  })
}

// 批量测试连接
export function batchTestConnection(deviceIds) {
  return request({
    url: '/devices/batch/test-connection',
    method: 'post',
    data: { deviceIds }
  })
}

// 批量获取设备信息
export function batchGetDeviceInfo(deviceIds) {
  return request({
    url: '/devices/batch/info',
    method: 'post',
    data: { deviceIds }
  })
}